home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue34 / system / RichEdit2.pas < prev   
Pascal/Delphi Source File  |  1998-05-08  |  3KB  |  112 lines

  1. unit RichEdit2;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ComCtrls, RichEdit;
  8.  
  9. type
  10.     TRichEdit2 = class (TCustomRichEdit)
  11.     private
  12.         { Private declarations }
  13.         fLibHandle: THandle;
  14.         procedure WMNCDestroy (var Message: TWMNCDestroy); message wm_NCDestroy;
  15.     protected
  16.         { Protected declarations }
  17.         procedure CreateParams (var Params: TCreateParams); override;
  18.     public
  19.         { Public declarations }
  20.     published
  21.         { Published declarations }
  22.         property Align;
  23.         property Alignment;
  24.         property BorderStyle;
  25.         property Color;
  26.         property Ctl3D;
  27.         property DragCursor;
  28.         property DragMode;
  29.         property Enabled;
  30.         property Font;
  31.         property HideSelection;
  32.         property HideScrollBars;
  33.         property ImeMode;
  34.         property ImeName;
  35.         property Lines;
  36.         property MaxLength;
  37.         property ParentColor;
  38.         property ParentCtl3D;
  39.         property ParentFont;
  40.         property ParentShowHint;
  41.         property PlainText;
  42.         property PopupMenu;
  43.         property ReadOnly;
  44.         property ScrollBars;
  45.         property ShowHint;
  46.         property TabOrder;
  47.         property TabStop default True;
  48.         property Visible;
  49.         property WantTabs;
  50.         property WantReturns;
  51.         property WordWrap;
  52.         property OnChange;
  53.         property OnDragDrop;
  54.         property OnDragOver;
  55.         property OnEndDrag;
  56.         property OnEnter;
  57.         property OnExit;
  58.         property OnKeyDown;
  59.         property OnKeyPress;
  60.         property OnKeyUp;
  61.         property OnMouseDown;
  62.         property OnMouseMove;
  63.         property OnMouseUp;
  64.         property OnResizeRequest;
  65.         property OnSelectionChange;
  66.         property OnStartDrag;
  67.         property OnProtectChange;
  68.         property OnSaveClipboard;
  69.     end;
  70.  
  71. procedure Register;
  72.  
  73. implementation
  74.  
  75. {$R *.DCR}
  76.  
  77. procedure TRichEdit2.CreateParams (var Params: TCreateParams);
  78. const
  79.     HideScrollBars: array[Boolean] of Longint = (ES_DISABLENOSCROLL, 0);
  80.     HideSelections: array[Boolean] of Longint = (ES_NOHIDESEL, 0);
  81. var
  82.     OldError: Longint;
  83. begin
  84.     OldError := SetErrorMode (sem_NoOpenFileErrorBox);
  85.     fLibHandle := LoadLibrary ('RICHED20.DLL');
  86.     SetErrorMode (OldError);
  87.     if (fLibHandle > 0) and (fLibHandle < hInstance_Error) then fLibHandle := 0;
  88.  
  89.     inherited CreateParams (Params);
  90.     if fLibHandle <> 0 then CreateSubClass (Params, 'RICHEDIT20A')
  91.     else CreateSubClass (Params, 'RICHEDIT');
  92.  
  93.     with Params do
  94.     begin
  95.         Style := Style or HideScrollBars [Inherited HideScrollBars] or HideSelections[HideSelection];
  96.         WindowClass.style := WindowClass.style and not (cs_HRedraw or cs_VRedraw);
  97.     end;
  98. end;
  99.  
  100. procedure TRichEdit2.WMNCDestroy (var Message: TWMNCDestroy);
  101. begin
  102.     Inherited;
  103.     if fLibHandle <> 0 then FreeLibrary (fLibHandle);
  104. end;
  105.  
  106. procedure Register;
  107. begin
  108.   RegisterComponents('XFactor', [TRichEdit2]);
  109. end;
  110.  
  111. end.
  112.